#include "widget.h"
#include "ui_widget.h"
#include <QResizeEvent>
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    //获取窗口的尺寸
    QRect rect = this->geometry();
    //先给label设置好尺寸
    ui->label->setGeometry(0,0,rect.width(),rect.height());
    //获取图片
    QPixmap pixmap(":/huaji.png");
    ui->label->setPixmap(pixmap);
    //添加伸缩属性
    ui->label->setScaledContents(true);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::resizeEvent(QResizeEvent *event)
{
   ui->label->setGeometry(0,0,event->size().width(),event->size().height());
   //打印一下
   qDebug() << event->size();
}

